package common;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;

/**
 * This class is used to pass the information between client and server. 
 * Due to the nature of this application it is convenient that the informational data is passed
 * between client and server by means of serializable classes. 
 * This kind of simplification is completely sufficient for our needs. <br>
 * It implements basic methods used frequently in the rest of the code.<br>
 * Class implements interface Serializable for it is often a return object of return method. 
 */
public final class ServerGetResult implements Serializable {
	/**
	 * The serial version unique identifier (SUID) of a class is a 64-bit hashcode computed from all the
	 * class's properties: its classname, the names of all interfaces which it implements, and the names
	 * and signatures of its member functions and fields. The SUID is identical for all versions of a class
	 * which are compatible under serialization.
	 * The serial version unique identifier (SUID) of a class is a 64-bit hashcode computed from all the
	 * class's properties: its classname, the names of all interfaces which it implements, and the names
	 * and signatures of its member functions and fields. The SUID is identical for all versions of a class
	 * which are compatible under serialization.
	 */
	private static final long serialVersionUID = 916911216077897743L;  // required by Serializable
	/**
	 * When client invokes @see daemon.Storage#get(String, String) method this filed is passed along other to
	 * inform client about the file-specific number. This information is possessed by server only.  
	 */
	public final int fileID;
	/**
	 * When client invokes @see daemon.Storage#get(String, String) method this filed is passed along other to
	 * inform client about the number of packages the file is divided into. This information is essential 
	 * for a client in order to execute the remaining part of get-process.
	 */
	public final int packageCount;
	/**
	 * When client invokes @see daemon.Storage#get(String, String) method this filed is passed along other to
	 * inform client about the network localizations of file parts. 
	 */
	public final Map<Integer,Collection<NetLocation>> partLocations;
	/**
	 * Basic constructor of a class.
	 * @param fileID When client invokes @see daemon.Storage#get(String, String) method this filed is passed along other to
	 * inform client about the file-specific number. This information is possessed by server only. 
	 * @param packageCount When client invokes @see daemon.Storage#get(String, String) method this filed is passed along other to
	 * inform client about the number of packages the file is divided into. This information is essential 
	 * for a client in order to execute the remaining part of get-process.
	 * @param partLocations When client invokes @see daemon.Storage#get(String, String) method this filed is passed along other to
	 * inform client about the network localizations of file parts. 
	 */
	public ServerGetResult(int fileID, int packageCount, Map<Integer,Collection<NetLocation>> partLocations) {
		this.fileID = fileID;
		this.packageCount = packageCount;
		this.partLocations = partLocations;
	}
}
